<template>
	 <ex-dialog v-model="visible" draggable :title="'编辑盘点明细'"
	width="1000" :contentHeight="450">

	  <template #default>

		  <el-form label-width="100" label-position="right" style="padding: 10px 10px 0 10px;">
				<el-row>
					<el-col :span="8">
						<el-form-item label="资产名称:" class="stockview">
							{{ form.assetName }}
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="资产编码:" class="stockview">
							{{ form.assetCode }}
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="财务编码:" class="stockview">
							{{ form.ncCode }}
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="8">
						<el-form-item label="资产类别:" class="stockview">
							<ex-label :key="form.assetCategory" code="FamsAssetCategory" :value="form.assetCategory"></ex-label>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="规格型号:" class="stockview">
							{{ form.model }}
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="资产原值:" class="stockview">
							{{ form.originalValue }}
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="8">
						<el-form-item label="资产净值:" class="stockview">
							{{ form.netValue }}
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="使用人:" class="stockview">
							<ex-label :key="form.usingUser" code="SysUser" :value="form.usingUser"/>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="使用部门:" class="stockview">
							<ex-label :key="form.usingOrg" code="SysOrganization" :value="form.usingOrg"/>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="8">
						<el-form-item label="实际使用人:" class="stockview">
							<ex-label :key="form.realityUsingUser" code="SysUser" :value="form.realityUsingUser"/>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="资产位置:" class="stockview">
							<ex-label :key="form.assetPosition" code="FamsPosition" :value="form.assetPosition"/>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="数量:" class="stockview">
							{{form.assetCount}}
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="8">
						<el-form-item label="盘点数量:" class="stockview">
							{{form.checkAccount}}
						</el-form-item>
					</el-col>

				</el-row>
				<el-row>
					<el-col :span="24">
						<el-form-item label="盘点备注说明:" class="stockview">
							<el-input type="textarea" v-model="form.checkDescription"></el-input>
						</el-form-item>
					</el-col>

				</el-row>
		  </el-form>
	  </template>
	  <template #footer>
		<div style="flex: auto;text-align: center">
		  <el-button plain type="primary" @click="save" :loading="loading">保 存</el-button>
		  <el-button plain type="warning" @click="reset" :loading="loading">重 置</el-button>
		  <el-button plain type="info" @click="this.visible = false" :loading="loading">关 闭</el-button>
		</div>
	  </template>

	</ex-dialog>
  </template>

  <script>
  import scIconSelect from '@/components/scIconSelect'
  import ExRelTable from "@/components/exRelTable/index.vue";
  import ExLabel from "@/components/exLabel/index.vue";
  import ExSelect from "@/components/exSelect/index.vue";
  import exDialog from '@/components/exDialog';

  export default {
	emits: ['success'],
	components: {
		ExSelect,
		ExLabel,
	  ExRelTable,
	  scIconSelect,
	  exDialog
	},
	props: {
	  menu: {
		type: Object, default: () => {
		}
	  },
	},
	data() {
	  return {
		visible: false,
		form: {
			id: "",
			assetName: "",
			assetCode: "",
			ncCode: "",
			status: "",
			checkDescription:"",
		},
		loading: false,
		oldForm: null,
	  }
	},
	  mounted() {

	},
	onLoad() {},
	methods: {
	  relHandler(relMap) {
		if (!this.form.relMaps) {
		  this.form.relMaps = {};
		}
		for (let key in relMap) {//清空旧的数据
		  this.form.relMaps[key] = {};
		}
		//重新赋值新数据
		Object.assign(this.form.relMaps, relMap);
	  },
		reset() {
			this.form = this.$TOOL.objCopy(this.oldForm);
		},
	  //显示
	  open(entity) {
		  this.form = {};
		this.form = this.$TOOL.objCopy(entity);
		this.oldForm = this.$TOOL.objCopy(this.form);
		this.visible = true;
	  },
	  //保存
	  async save() {
		  try {
			  let documet = {
				  id: this.form.id,
				  checkDescription: this.form.checkDescription,
			  }
			  this.loading = true
			  var res = await this.$API.asset.checkDetailApi.edit.post(documet)
			  if (res.code === 2000) {
				  this.$emit('success');
				  this.$message.success(this.$t("code."+res.code));
				  this.visible = false;
				  this.$store.dispatch("commit",this.form.entityName);
			  } else {
				  this.$message.warning(res.message)
			  }
		  } finally {
			  this.loading = false
		  }
	  },
	}
  }
  </script>

  <style scoped>
  h2 {
	font-size: 17px;
	color: #3c4a54;
	padding: 0 0 30px 0;
  }

  [data-theme="dark"] h2 {
	color: #fff;
  }
  .label-center{
	  display: flex;
	  justify-content: center;
	  align-items: center;
  }

  .stockview {
    padding-top: 3.5px;
    margin-left: 10px;
    margin-right: 10px;
    padding-bottom: 6.5px;
    border-bottom: 1px solid #e8f1ff;
}
  </style>
